<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ count }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: isSel === 'all' }"
          href="javascript:;"
          @click="selected('all')"
          >全部</a
        >
      </li>
      <li>
        <a
          href="javascript:;"
          :class="{ selected: isSel === 'none' }"
          @click="selected('none')"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: isSel === 'done' }"
          href="javascript:;"
          @click="selected('done')"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="clearFn">清除已完成</button>
  </footer>
</template>

<script>
export default {
  data() {
    return {
      isSel: "all",
    };
  },
  props: ["list"],
  computed: {
    count() {
      return this.list.length;
    },
  },
  methods: {
    selected(val) {
      this.isSel = val;
      this.$emit("changeType", this.isSel);
    },
    clearFn() {
      this.$emit("clearDone");
    },
  },
};
</script>